/*
 * DOMCharactersProxy.java
 *
 * Created on September 4, 2006, 1:05 PM
 *
 * (C) 2006 R. Alexander Milowski
 */

package org.infoset.xml.dom;

import org.infoset.xml.Comment;
import org.infoset.xml.Text;
import org.w3c.dom.Node;

/**
 *
 * @author alex
 */
public class DOMCommentProxy extends DOMChildProxy implements org.w3c.dom.Comment{
   
   /** Creates a new instance of DOMCharactersProxy */
   public DOMCommentProxy(Comment item,DOMDocumentProxy docProxy) {
      super(item,docProxy);
   }
   
   public short getNodeType() {
      return Node.COMMENT_NODE;
   }
   
   public String getNodeValue() {
      return getTextContent();
   }
   
   public void setNodeValue(String value) {
      setTextContent(value);
   }
   
   public String getNodeName() {
      return "#comment";
   }
   
   public void setTextContent(String value) {
      Text t = (Text)item;
      t.setText(value);
   }
   
   public String getTextContent() {
      Text t = (Text)item;
      return t.getText();
   }
   
   public Node cloneNode(boolean deep) {
      return new DOMCommentProxy((Comment)item.copyOfItem(deep),documentProxy);
   }
   
   public void replaceData(int offset, int count, String arg) {
      String text = getTextContent();
      text = text.substring(0,offset)+arg+text.substring(offset+count);
      setTextContent(text);
   }
   public void deleteData(int offset, int count) {
      String text = getTextContent();
      text = text.substring(0,offset)+text.substring(offset+count);
      setTextContent(text);
   }
   public void insertData(int offset, String arg) {
      String text = getTextContent();
      text = text.substring(0,offset)+arg+text.substring(offset);
      setTextContent(text);
   }
   public void appendData(String arg) {
      String text = getTextContent();
      text = text+arg;
      setTextContent(text);
   }
   public String substringData(int offset,int count) {
      String text = getTextContent();
      return text.substring(offset,offset+count);
   }

   public int getLength() {
      return getTextContent().length();
   }
   
   public void setData(String text) {
      setTextContent(text);
   } 
   
   public String getData() {
      return getTextContent();
   }
}
